<?php 
include_once(''.P.'/public/header.html');
?>

<script type="text/javascript" src="res/bootstrapplugin/jquery-bootstable.js"></script>


<script>
var opttype = '<?=$type?>';
function initbody(){
	
}
function save(o1){
	var da = js.getformdata();
	js.setmsg('保存中...');
	o1.disabled=true;
	da.type = opttype;
	js.ajax({
		type:'post',
		url:'?m=cog&a=savecheck',
		data:da,
		success:function(res){
			o1.disabled=false;
			if(res=='ok'){
				js.setmsg('保存成功','green');
			}else{
				js.setmsg(res);
			}
		}
	});
}
function xuancolor(){
	var zys = ['#1389D3','#99cc66','#003366','#6666CC','#CC3333','#009966','#333333','#990066','#333300','#333366','#99CC99','#663366','#003399','#666699'];
	var h = '<div style="padding:10px"><table class="cursor"><tr>';
	for(var i=0;i<zys.length;i++){
		h+='<td width="20" onclick="xuancolora(\''+zys[i]+'\')" width="20" bgcolor="'+zys[i]+'">&nbsp;</td>';
	}
	h+='</tr></table></div>';
	js.tanbody('color','选择主题颜色',310,200,{
		html:h
	});
}
function xuancolora(col){
	form('apptheme').value=col;
	js.tanclose('color');
}
function yzurl(o1){
	var s = o1.value;
	if(!s)return;
	if(s.substr(0,4)!='http')s='http://'+s+'';
	if(s.substr(s.length-1,1)!='/')s+='/';;
	o1.value = s;
}
</script>
<style>
.caidan{padding:10px;text-align:left;border-bottom:1px #eeeeee solid;cursor:pointer}
.caidan:hover{background-color:rgba(0,0,0,0.05)}
.caidan.active{background-color:rgba(0,0,0,0.06)}
</style>
</head>

<body>

<?php 
include_once(''.P.'/public/top.html');
?>

<div align="center">

<div style="width:<?=$maxwidth?>;margin:20px 0px" align="left">
	<div style="color:#cccccc">
		<a href="?m=index" class="zhu"><?=lang('admin.home')?></a> &gt;
		<a href="" class="zhu"><?=lang('admin.cogtitle')?></a>
	</div>
	
	<div style="background-color:white;margin:20px 0px;border:1px #eeeeee solid;border-radius:5px">
	
	<table width="100%">
	<tr valign="top">
	<td>
	<div style="width:180px;background:#f9f9f9;min-height:500px;border-right:1px #f1f1f1 solid">
		
		<div class="caidan<?php if(isempt($type))echo ' active';?>">◇ <a href="?m=cog">系统设置</a></div>
		<div class="caidan<?php if($type=='only')echo ' active';?>">◇ <a href="?m=cog&type=only">OnlyOffice设置</a></div>
		<div class="caidan<?php if($type=='wps')echo ' active';?>">◇ <a href="?m=cog&type=wps">WPS文档服务</a></div>
		<div class="caidan<?php if($type=='server')echo ' active';?>">◇ <a href="?m=cog&type=server">服务端设置</a></div>
		<div class="caidan<?php if($type=='gengxin')echo ' active';?>">◇ <a href="?m=cog&type=gengxin">系统升级</a></div>
		
	</div>
	</td>
	
	<td width="90%">
	
	<?php if(isempt($type)){?>
	<div style="padding:30px 30px">
		<form name="myform"  autocomplete="off">
		<table>
	
		<tr><td height="10"></td></tr>
		
		<tr><td align="right" style="color:gray">系统名称：</td><td><input name="title" type="text" value="<?=getconfig('title')?>" style="width:260px" class="input"></td></tr>
		<tr><td height="10"></td></tr>
		
		<tr><td align="right" style="color:gray">系统外网地址：</td><td><input name="outurl" placeholder="有就设置，没有就不要乱设置" onblur="yzurl(this)" type="text" value="<?=getconfig('outurl')?>" style="width:260px" class="input"></td></tr>
		<tr><td height="10"></td></tr>
		
		<tr><td align="right" style="color:gray">系统本地地址：</td><td><input name="localurl" placeholder="有就设置，没有就不要乱设置" onblur="yzurl(this)" type="text" value="<?=getconfig('localurl')?>" style="width:260px" class="input"></td></tr>
		<tr><td height="10"></td></tr>
		
		<tr><td align="right" style="color:gray">信呼官网key：</td>
		<td >
		<input placeholder="必须，否则无法升级" type="text" value="<?=$xhrock->getxings(getconfig('xinhukey'))?>" name="xinhukey" style="width:260px" class="input">
		<span style="color:#aaaaaa;"><a href="<?=URLY?>view_xhkey.html" target="_blank" >看帮助获取</a></span>
		</td></tr>
		<tr><td height="10"></td></tr>
		
		<tr><td align="right" style="color:gray">文档预览方式：</td>
		<td>
		<select name="officebj_fan" style="width:260px" class="input">
		<option value="0">编辑平台WPS</option>
		<option value="1"<?php if(getconfig('officebj_fan')=='1')echo' selected';?>>使用OnlyOffice服务</option>
		<option value="4"<?php if(getconfig('officebj_fan')=='4')echo' selected';?>>信呼官网转PDF预览服务</option>
		<option value="2"<?php if(getconfig('officebj_fan')=='2')echo' selected';?>>微软服务(需要域名80端口)</option>
		</select></td></tr>
		<tr><td height="10"></td></tr>
		
		<tr><td align="right" style="color:gray">文档编辑方式：</td>
		<td>
		<select name="officebj_edit" style="width:260px" class="input">
		<option value="0">编辑平台WPS</option>
		<option value="1"<?php if(getconfig('officebj_edit')=='1')echo' selected';?>>使用OnlyOffice服务</option>
		</select></td></tr>
		<tr><td height="10"></td></tr>
		
		<tr><td align="right" style="color:gray">编辑平台地址：</td><td>
		<input placeholder="你自己部署就要设置" onblur="yzurl(this)" type="text" value="<?=getconfig('officebj_url')?>" name="officebj_url" style="width:260px" class="input"><span style="color:#aaaaaa;">
		<a href="<?=URLY?>view_rockoffice.html" target="_blank" >部署编辑平台</a></span>
		</td></tr>
		<tr><td height="10"></td></tr>
		
		<tr><td align="right" style="color:gray">编辑平台key：</td><td>
		<input placeholder="从文档编辑平台上获取" type="text" value="<?=$xhrock->getxings(getconfig('officebj_key'))?>" name="officebj_key" style="width:260px" class="input">
		<span style="color:#aaaaaa;">从<a href="<?=URLY?>view_agentkey.html" target="_blank" >编辑平台</a>获取</span>
		</td></tr>
		<tr><td height="10"></td></tr>
		
		<tr><td align="right" style="color:gray">系统主题色：</td><td><input name="apptheme" type="text" value="<?=getconfig('apptheme')?>" style="width:210px;border-radius:5px 0px 0px 5px;border-right:0" maxlength="7" placeholder="#开头的RGB格式如：#99cc66" class="input"><button onClick="xuancolor()" class="webbtn webbtn-white" style="height:36px;border-radius:0px 5px 5px 0px" type="button" >选择</button></td></tr>
		<tr><td height="10"></td></tr>
		
		<tr><td align="right"></td><td>
		<button type="button" onClick="save(this)" style="padding:8px 20px;border-radius:5px" class="webbtn" >保存</button>&nbsp;<span id="msgview"></span>
		</td></tr>
		
		</table>
		<div style="color:#aaaaaa;margin-top:10px">更多请到配置文件：webmain/webmainConfig.php下设置</div>
		</form>
	</div>
	<?php }?>
	
	<?php if($type=='only'){?>
	<div style="padding:30px 30px">
		<form name="myform"  autocomplete="off">
		<table>
	
		<tr><td height="10"></td></tr>
		
		<tr><td colspan="2" align="center">OnlyOffice是一个强大的文档编辑预览服务，免费使用社区版，他们<a href="https://www.onlyoffice.com/zh" target="_blank">官网</a>。</td></tr>
		<tr><td height="20"></td></tr>
		
		<tr><td align="right" style="color:gray">OnlyOffice地址：</td><td><input name="onlyoffice_url" type="text" value="<?=getconfig('onlyoffice_url')?>"  onblur="yzurl(this)" placeholder="http开头" style="width:260px" class="input"><br><span style="color:#aaaaaa;font-size:12px">如果你没有部署onlyoffice就不要设置，<br>默认是官网提供服务(本站点需部署外网)，<a href="<?=URLY?>view_onlyoffice.html" target="_blank" style="font-size:12px">部署帮助</a>。</span></td></tr>
		<tr><td height="10"></td></tr>
		
		<tr><td align="right"></td><td>
		<button type="button" onClick="save(this)" style="padding:8px 20px;border-radius:5px" class="webbtn" >保存</button>&nbsp;<span id="msgview"></span>
		</td></tr>
		
		</table>
		
		</form>
	</div>
	<?php }?>
	
	<?php if($type=='wps'){?>
	<div style="padding:30px 30px">
		<form name="myform"  autocomplete="off">
		<table>
	
		<tr><td height="10"></td></tr>
		
		<tr><td colspan="2" align="center">WPS开发平台提供预览编辑文档服务，他们<a href="https://open.wps.cn/" target="_blank">官网</a>。</td></tr>
		<tr><td height="20"></td></tr>
		
		<tr><td align="right" style="color:gray">APPID：</td><td><input name="wpsapp_id" type="text" value="<?=$xhrock->getxings(getconfig('wpsapp_id'))?>" placeholder="" style="width:260px" class="input"></td></tr>
		<tr><td height="10"></td></tr>
		
		<tr><td align="right" style="color:gray">APPKEY：</td><td><input name="wpsapp_key" type="text" value="<?=$xhrock->getxings(getconfig('wpsapp_key'))?>" placeholder="" style="width:260px" class="input"><br><span style="color:#aaaaaa;font-size:12px">从WPS开发平台中获取，没有就不用设置</span></td></tr>
		<tr><td height="10"></td></tr>
		
		<tr><td align="right"></td><td>
		<button type="button" onClick="save(this)" style="padding:8px 20px;border-radius:5px" class="webbtn" >保存</button>&nbsp;<span id="msgview"></span>
		</td></tr>
		
		</table>
		
		</form>
	</div>
	<?php }?>
	
	<?php if($type=='server'){?>
	<script>     
	function texttongs(){
		js.loading('测试中...');
		js.ajax({
			url:'?a=textpush&m=cog',
			dataType:'json',
			success:function(ret){
				if(ret.success){
					js.msgok(ret.data);
				}else{
					js.msgerror(ret.msg);
				}
			}
		});
	}
	function shezhis(){
		js.prompt('请输入您服务器IP', function(jg,txt){
			if(jg=='yes' && txt){
				form('server_push').value='http://127.0.0.1:6553/';
			}
		},'服务端设置');
	}
	</script>
	<div style="padding:30px 30px">
		<form name="myform" autocomplete="off">
		<input value="<?=$type?>" name="type" type="hidden">
		<table>
		<tr><td height="10"></td></tr>
		
		<tr><td colspan="2" align="center"><input type="button" value="快速设置" onclick="shezhis()"  class="webbtn webbtn-white"><br>服务端是提供异步的处理功能，看<a href="<?=URLY?>view_rockservice.html" target="_blank">帮助</a>安装。</td></tr>
		<tr><td height="20"></td></tr>

		<tr><td align="right" style="color:gray">服务端推送地址：</td>
		<td >
		<input type="text" value="<?=getconfig('server_push')?>"  onblur="yzurl(this)" placeholder="默认是http://127.0.0.1:6553/" name="server_push" style="width:260px" class="input">
		</td></tr>
		<tr><td height="10"></td></tr>
		
		<tr><td align="right" style="color:gray">PHP路径：</td>
		<td >
		<input type="text" value="<?=getconfig('phppath')?>" placeholder="加入环境变量设置：php，即可" name="phppath" style="width:260px" class="input">
		</td></tr>
		<tr><td height="10"></td></tr>
		

		
		<tr><td align="right"></td><td>
		<button type="button" onClick="save(this)" style="padding:8px 20px;border-radius:5px" class="webbtn" >保存</button>&nbsp;
		<a href="javascript:;" class="zhu" onclick="texttongs()">测试推送地址</a>&nbsp;
		<span id="msgview"></span>
		</td></tr>
		
		</table>
		</form>
	</div>
	<?php }?>
	
	<?php if($type=='gengxin'){?>
	<div style="padding:30px 30px">
		<form name="myform"  autocomplete="off">
		<table>
	
		<tr><td height="10"></td></tr>
		
		<tr><td colspan="2" align="center">一键获取最新程序更新，会覆盖修改的文件哦，建议做好备份，系统程序由<a href="http://www.rockoa.com/view_<?=getconfig('sysfrom')?>.html" target="_blank">信呼官网</a>提供。</td></tr>
		<tr><td height="20"></td></tr>
	
		
		<tr><td align="right"></td><td>
		<button type="button" onclick="jianchegst(this)" class="webbtn" >检查更新</button>&nbsp;<span id="msgview"></span>
		<div id="gengsupstr"></div>
		</td></tr>
		
		</table>
		
		</form>
	</div>
	<script>
	function jianchegst(o1){
		js.loading('检查中...');
		o1.disabled=true;
		js.ajax({
			url:'?a=gengxin&m=cog',
			dataType:'json',
			success:function(ret){
				js.unloading();
				if(ret.success){
					var da = ret.data;
					if(da.isup==1){
						js.confirm(da.sm, function(jg){if(jg=='yes')gegnxin();});
					}else{
						js.msgok(da.sm);
					}
				}else{
					js.msgerror(ret.msg);
				}
			}
		});
	}
	function gegnxin(){
		js.loading('更新中...');
		js.setmsg('更新中...');
		js.ajax({
			url:'?a=okgengk&m=cog',
			dataType:'json',
			success:function(ret){
				js.unloading();
				js.setmsg();
				if(ret.success){
					js.msgok(ret.data);
					$('#gengsupstr').html(ret.filestr);
				}else{
					js.msgerror(ret.msg);
				}
			}
		});
	}
	</script>
	
	<?php }?>
	
	
	</td>
	</tr>	
	</table>


	</div>
</div>



<?php 
include_once(''.P.'/public/footer.html');
?>
</div>

</body>
</html>